/** ###################################################################
**     Filename  : pwm.C
**     Project   : pwm
**     Processor : 56F8013VFAE
**     Version   : Driver 01.14
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 2012-3-9, 16:30
**     Abstract  :
**         Main module.
**         This module contains user's application code.
**     Settings  :
**     Contents  :
**         No public methods
**
** ###################################################################*/
/* MODULE pwm */


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "PWM1.h"
#include "ADC1.h"
#include "PWM2.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
//PESL(ADC1_DEVICE, ADC_ZERO_CROSS_CH5, ...);

word i=0;
int flag=1;
void main(void)
{
  /* Write your local variable definition here */
  
//  extern unsigned int _vba;
//  INTC_VBA = (unsigned int)&_vba >>7 ; // restore VBA register to point to user defined vector table

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/
PESL(ADC1_DEVICE, ADC_START, NULL);

  /* Write your code here */

  PWM1_Enable();
  PWM2_Enable();

  for(;;) {
  
  if(flag)
  {
  	 PWM1_SetRatio16(i);
  	 PWM2_SetRatio16(0);

     Cpu_Delay100US(20); 
     i++; 	
     if(i>65534)
       flag=0;
  }
  else
  {
  	 PWM1_SetRatio16(i);
  	 PWM2_SetRatio16(0);
     Cpu_Delay100US(20); 
     i--; 	
     if(i<1)
       flag=1;  	
  }
  
  

  
//  PWM1_SetRatio8(100);

  
  }
}

/* END pwm */
/*
** ###################################################################
**
**     This file was created by Processor Expert 3.00 [04.35]
**     for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
